import React, { useState } from 'react';
import style from '../index.less';
import { history, IRouteComponentProps, useModel } from 'umi';
import { PageHeader } from 'antd';
import { useEffect } from 'react';
const My: React.FC<IRouteComponentProps> = ({ match, route }): any => {
    let { getAddressData } = useModel('main', model => ({ getAddressData: model.getAddressData }));
    let [list, setList] = useState([])
    async function getAddressdata() {
        let res = await getAddressData()
        console.log(res);
        setList(res)
    }
    function ht() {
        history.go(-1)
    }
    useEffect(() => {
        getAddressdata()

    }, [getAddressData])
    return (
        <div className={style.address}>
            <PageHeader
                className={style.siteheader}
                onBack={() => ht()}
                title=""
                subTitle="购物详情"
            />
            <div className={style.address_h}>
                {
                    (list as unknown as any).map((item:any,index:number)=>{
                        return (
                            <li key={index}>
                                <span>代号:{item.address}</span>
                                <span>名称:{item.name}</span>
                                <span>地址:{item.city_name}-{item.district_name}</span>
                                <span>详细地址:{item.full_region}</span>
                                <span><button>编辑</button><button>删除</button></span>
                            </li>
                        )
                    })
                }
            </div>
            <div className={style.address_f}>
                <span>新增地址</span>
            </div>
        </div>
    )
}
export default My